package com.yanqu.road.dao.impl.activity.yuanbaolottery;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dao.impl.TempDao;
import com.yanqu.road.entity.activity.yuanbaolottery.YuanBaoLotteryConfig;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class YuanBaoLotteryConfigDaoImpl extends TempDao {
    private static String getYuanBaoLotteryConfigSql = "select * from `t_s_activity_yuanbao_lottery` where `activityId`=?";
    public List<YuanBaoLotteryConfig> getYuanBaoLotteryConfigMap(int activityId) {
        List<YuanBaoLotteryConfig> dataList = new ArrayList<>();
        ResultSet rs = null;
        CallableStatement call = null;
        try {
            getDb().setConnName(DbNameStrategy.getServerDb());
            call = getDb().getConnection().prepareCall(getYuanBaoLotteryConfigSql);
            int i = 1;
            call.setInt(i++, activityId);
            rs = call.executeQuery();
            while (rs.next()) {
                YuanBaoLotteryConfig yuanBaoLotteryConfig = new YuanBaoLotteryConfig(rs);
                dataList.add(yuanBaoLotteryConfig);
            }
        } catch (Exception e) {
            logger.error(Thread.currentThread().getStackTrace()[1].getMethodName() + ":", e);
        } finally {
            getDb().closeConnection(call, rs);
        }
        return dataList;
    }

}
